﻿using System;
using System.Linq;

namespace Sample.Models
{
    public static class LastModifiedUpdater
    {
        public static void SavingChanges(object sender, EventArgs e)
        {
            var ctx = (MyEntityContext) sender;
            foreach (var task in ctx.TrackedObjects.Where(x => x is ITask && x.IsModified).Cast<ITask>())
            {
                task.LastModified = DateTime.Now;
            }
        }
    }
}
